import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver, AntDesignVueResolver, NaiveUiResolver} from 'unplugin-vue-components/resolvers'
// https://vitejs.dev/config/


export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      resolvers: [ElementPlusResolver(), AntDesignVueResolver(), NaiveUiResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver(), AntDesignVueResolver(), NaiveUiResolver()],
    }),
  ],

  base: './', // 打包路径

  server:{
	host:['0.0.0.0'],
    //host:'0.0.0.0' ,//ip地址
    port: 8888, // 设置服务启动端口号
    open: true, // 设置服务启动时是否自动打开浏览器
    proxy: {
      '/api': {
        target: 'https://pvp.qq.com/',	//实际请求地址
        changeOrigin: true, //允许跨域
        secure: false,  //默认为true，是否需要携带安全证书，即https时，是需要的，设置成false就不用了
        rewrite: (path) => path.replace(/^\/api/, '')
      },
      '/api1': {
        target: 'https://gitee.com/',	//实际请求地址
        changeOrigin: true, //允许跨域
        secure: false,  //默认为true，是否需要携带安全证书，即https时，是需要的，设置成false就不用了
        rewrite: (path) => path.replace(/^\/api1/, '')
      },
    },
  }
})
